**TEXT METHODS WILL ALWAYS BE BETTER THAN VIDEOS ON YOUTUBE OR VIDEO AT ALL**
**AS YOU CAN GET A BETTER VISUAL IDEA THAN A SHITTY INDIAN POO IN THE LOO VIDEO**


How to make your own modern NGINX server on freebsd (works on the shitty GNU aka linux bloat alpinelinux is kindda chadish cuz they use Busybox and avoid the massive bloat that systemd is forget security )

NOTES: AND CLEARANCE


A. ( I AM NOT GOING TRU FIREWALL RULES AS I AM FUCKING LAZY AS I DISABLED THE FIREWALL AND ALLOW ANY FAG ON THE INTERNET TO SEE ANY PORT I HAVE )

B. Actually setting this requrie basic knowledge of google and understanding how to get your own ssl-certificates via Certbot/LetsEncrypt

C. this method teaches you how to add a deamon too

E. You need to install golang

G. It has 8-7 seconds delay even behind cloudflare

F. WE WILL USE ROOT BECAUSE I AM A FAGGOT, YOU ARE mORE THAN WELCOME TO USE JAILS (WHAT DOCKER WILL NEVER BE) - if you dont want your bank details get leaked you are in the wrong place because you should be running it under QEMU/VirtualBox or I_dont_give_a_flying_fuck_hardware

--- *DONT TYPE BLINDLY UNDERSTAND WHAT EACH COMMAND MEANS* 
--- **AND NEXT TIME YOU WILL GET YOUR OWN UNDERSTANDING OF GETTING OTHER COOLWARE, WORKING ON YOUR 3.65$ VPS (I use Kamatera as they provide really really networking and a lot of locations and not a lot of hassle can be done there)**

Installing Golang
```
cd /tmp
curl -LO https://go.dev/dl/go1.17.8.freebsd-amd64.tar.gz
tar -C /usr/local -xzf go1.17.8.freebsd-amd64.tar.gz
```

add Golang to your PATH
```
vim 
setenv GOPATH /root/.gopkg
set path = ($path /usr/local/go/bin /root/.gopkg/bin)
```

First you need the RTMP server 
so 

```
#MAKE SURE YOU ARE ON THE USER ROOT
cd ~
mkdir src

cd src/
git clone https://github.com/aler9/rtsp-simple-server
go build
chmod +x ./rtsp-simple-server


# Run your binary
./rtsp-simple-server
#Now see everything is working (now you can even stream to the server)
```

replace the logical-port to 666 because why not? 
```
sed -i '' 's/rtmpAddress\: \:1935/rtmpAddress\: \:666/g' /root/src/rtsp-simple-server/rtsp-simple-server.yml
```

Okay great now I will play nice like I am your friend, but lets be honest you found this guild after hours 
of looking at the internet looking to leech basic humanine commands on your shitty terminal to get such a basic and simple thing working


now install NGINX  
```
pkg update && pkg upgrade
pkg install nginx certbot nano
```

Now you're set! 

now I want you to start on your nginx daemon/service
*FUN NOTE: (Daemon the meaning is actually service in English)*

now
```
service nginx start
```

now actually check if you got an NGINX server
```
curl http://localhost/
or 
join on your browser if your IP
http://EXTERNAL_IP/
```
should look like
![anime_is_degenerate](NGINXsoyBoy.png)

NOW MAKE A DAEMON FOR THE RTMP SERVER 

Q: What is a daemon ? 

A: **Like systemd/systemctl but readable and easy to use unlike systemd that once you get how to use it you still have no clue how to use it**



---------------------------------------------------------------
Installing a DAEMON/SERVICE will will reboot if the rtmp server crash, auto start when the server restarts too! just like MSCONFIG in windows! but better because a shellscript does it :) and you dont need to compile a shitty malware service-binary (however the fucking windows does it this days with installing 5gb of porn the 5 seconds you boot your pc) too hook up for such a simple task, moral of the story skin Microsoft and the talented developers that still work there like a dog. 

Copy all of the content/text you see in **rtmpserver**, which you can find in this git folder 
Do the following


EDIT THIS FILE IN THIS LOCATION (AKA IT WILL MAKE IT AS YOU ASK TO EDIT IT)
```
nano /usr/local/etc/rc.d/rtmpserver

put all of the text you see in this **rtmpserver** file you copied before. 
once you done it do 

chmod +x /usr/local/etc/rc.d/rtmp_enable
```

now add the rtmpserver daemon to your rc config
```
sysrc rtmp_enable=YES
```

now you should have an RTMP service, **if something doesnt work understand the point of every command and use google/yandex**

start your service 
```
service rtmpserver start 
```


now try getting a status from the daemon we created 
```
service rtmpserver status

service rtmpserver status

service rtmpserver status

run it few times see the PID number doesnt change which mean we managed to
get everything working and that it doesnt crashes in a loop and we set everything as we wanted
```


NOW LETS TRY TO STREAM ON OBS! And get an image via the software and see everything working as intended (BEFORE WE ARE Mirroring/proxing it on nginx)
![anime_is_degenerate](obsConfStream.png)



*now* you should be able to view it on 
http://EXTERNAL_IP:8888/mystream/lol/

***
***
the 'lol' is your private stream key you should make it stronger, or whatever dont tell anyone its that simple and sort
it can be changed to anything you want, but at first make it simple, 
you also dont wanna share this 8888 site too - this is just to check before we gonna proxy behind NGINX which will give us SSL and a different URL which will hide your private key and make it look nice - dont understand what I mean ! you will understand later on
***
***

EXTERNAL_IP is your external ip as you can already figure out by this image

![I_dislike_anime](schzio.png)

Good now you have an image
and you know your RTMP server works fine 


-------------------------------------
Configuring NGINX to reverse proxy your RTMP server - and adding ssl



```
mkdir /usr/local/www/live
```

copy this autistic index.html file to /usr/local/www/live
```
cp index.html /usr/local/www/live/index.html
```


```
get a subdomain named "rtmp"
```

AFTER you got a domain run cert bot by
```
service nginx stop
certbot certonly --cert-name rtmp.MYDOMAIN.com -d MYDOMAIN.com
# Choose ""1: Spin up a temporary webserver (standalone)""
service nginx start
````

now you should get your ssl certificates use more than 50IQ or you chinese social credit score to understand how to use it 
now you should have ssl certificates (if not make sure your rtmp subdomain still works)
now do the following command and do you the certificates in this folder 
```
ls /usr/local/etc/letsencrypt/live/
```

yes? You can see your certificates?
great! follow this tutorial


copy the nginx.conf into /usr/local/etc/nginx/nginx.conf
```
Use nano or an external editor on WinSCP  (If you are a chad use VIM)


![how_could_you_like_cute_chinese_anime_cartoons](changessl.png)

**change this ssl to your own ssl** use your brain to see where each file should go dont be confused with the privkey.pem and fullchain.pem 
you can just change it to your domain make **note off** that you have two ssl certificates one to your main website 
and one to your rtmp.MYDOMAIN.com

you changed this two now great 
now you should be able to stream on rtmps://rtmp.MYDOMAIN.com:1935/mystream
BE-WARE-OF-THE RTMPS 
there is an "S" which stands for SSL


![animu](doesthestreamworks.png)

Great the stream works? 
GREAT! you have nginx+rtmp+ssl now 

now go to the index.html file on /usr/local/www/live/index.html

edit the streaming url to whatever rtmp_stream you got
![AnimeRuinsPeopleLifes](uwu_final_stage.png)

you can have as many rtmp stream as you wish tho but understand it well how everything connects with each other get anything working 
before having fun 

anyways after that you should have a working RTMPS server 
![AnimeRuinsPeopleLifes](EndOFaSessionINlife_you_will_neverGET_back.png)


Enjoy your HD rtmps server 